<template>
	<view class="confirm-pop-wrap">
		<view class="confirm-pop-mask" @tap.stop="maskClk"></view>
		<view class="confirm-pop">
			<view class="pop-title">{{title}}</view>
			<view class="pop-content">{{content}}</view>
			<view class="pop-sub-content" v-if="subContent">{{subContent}}</view>
			<view class="pop-btns">
				<view  v-if="!hasShareBtn" class="pop-btn" :style="{'background-color':btn1.bgColor ||'#3399FF'}"
					@tap.stop="btnClk(btn1)">{{btn1.text}}</view>
				<button v-else class="pop-btn" :style="{'background-color':btn1.bgColor ||'#3399FF'}" 
				    open-type="share">{{btn1.text}}</button>
				<view class="pop-btn" :style="{'background-color':btn2.bgColor ||'#3399FF'}" @tap.stop="btnClk(btn2)">
					{{btn2.text}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "confirmPop",
		props: {
			title: {
				type: String,
				default: '提示'
			},
			content: {
				type: String,
				default: ''
			},
			subContent: {
				type: String,
				default: ''
			},
			btns: {
				type: Array,
				default () {
					return [{
						text: '确定',
						type: 'confirm'
					}, {
						text: '取消',
						type: 'cancel',
						bgColor:'#E5E5E5'
					}]
				}
			},
			hasShareBtn:{
				type: Boolean,
				default: false
			}
		},
		computed: {
			btn1() {
				if (!this.btns[0]) {
					return {
						text: '确定',
						type: 'confirm'
					}
				}
				return this.btns[0]
			},
			btn2() {
				if (!this.btns[1]) {
					return {
						text: '取消',
						type: 'cancel',
						bgColor:'#E5E5E5'
					}
				}
				return this.btns[1]
			},
		},
		data() {
			return {

			};
		},
		methods: {
			maskClk() {
				this.$emit('maskClk')
			},
			btnClk(item) {
				this.$emit('btnClk', item)
			}
		}
	}
</script>

<style lang="less">
	.confirm-pop-mask {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.3);
		z-index: 999;
	}

	.confirm-pop {
		position: fixed;
		top: 30%;
		left: 75rpx;
		width: 600rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		box-sizing: border-box;
		padding: 36rpx 72rpx 44rpx 72rpx;
		z-index: 1000;

		.pop-title {
			font-weight: 600;
			color: #333333;
			line-height: 50rpx;
			font-size: 36rpx;
			text-align: center;
		}

		.pop-content {
			margin-top: 30rpx;
			font-size: 30rpx;
			font-weight: 400;
			color: #323746;
			line-height: 48rpx;
			word-break: break-all;
		}
		.pop-sub-content{
			margin-top: 10rpx;
			font-size: 26rpx;
			font-weight: 400;
			color: #323746;
			line-height: 48rpx;
			word-break: break-all;
		}

		.pop-btns {
			width: 100%;
			margin-top: 38rpx;
			display: flex;
			justify-content: space-between;


			.pop-btn {
				border-radius: 6rpx;
				font-size: 32rpx;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 40rpx;
				padding: 18rpx 36rpx;
				min-width: 212rpx;
				box-sizing: border-box;
				text-align: center;

			}
		}
	}
</style>
